package main

import (
    "../rmq"
    "fmt"
    "time"
)

func callback(d rmq.MSG) {
    fmt.Println("Ok")
    fmt.Println(string(d.Body))
}

func errCallback(d rmq.MSG) {
    fmt.Println("Err")
    fmt.Println(string(d.Body))
}

func dlxCallback(d rmq.MSG) {
    fmt.Println("Dlx")
    fmt.Println(string(d.Body))
}

func main() {
    if err := rmq.Init("./rmq.json"); err != nil {
        fmt.Println(err)
    }

    if err := rmq.Pop("myPoper", callback); err != nil {
        fmt.Println(err)
    }


    if err := rmq.Pop("errPoper", errCallback); err != nil {
        fmt.Println(err)
    }

    if err := rmq.Pop("dlxPoper", dlxCallback); err != nil {
        fmt.Println(err)
    }

    time.Sleep(time.Duration(1000)*time.Second)

    if err := rmq.Fini(); err != nil {
        fmt.Println(err)
    }
}
